<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  function Person(name, age) {
    this.name = name;
    this.age = age;
  }

  Person.prototype.species = "chongbo";
  Person.prototype.skill = function () {
    console.log("冲波");
  }
  Person.prototype.say = function () {
    console.log(this.name, this.age);
  }

  var p = new Person("周冲波", 30);
  console.log(p);


  function YellowPerson(name, age, hobby) {
    // this.name = name;
    // this.age = age;

    Person.call(this, name, age)

    this.hobby = hobby;
  }

  //浅复制
  // YellowPerson.prototype = Person.prototype;

  // YellowPerson.prototype = new Person("周冲波", 30)
  // YellowPerson.prototype.constructor = YellowPerson;

  function Fn() { }
  Fn.prototype = Person.prototype;

  YellowPerson.prototype = new Fn();
  YellowPerson.prototype.constructor = YellowPerson;

  // YellowPerson.prototype.say = function () {
  //   console.log(this.name, this.age, this.hobby);
  // }

  YellowPerson.prototype.speak = function () {
    console.log("捉冲波");
  }
  var yp = new YellowPerson("冲波", 20, "干饭");
  console.log(yp);

  // console.log(yp.species);
  // yp.say();
  // yp.skill();
  // yp.speak();
</script>

</html>